package cn.zcscloud.mall.service.impl;

import cn.zcscloud.mall.mbg.mapper.SmsHomeBrandMapper;
import cn.zcscloud.mall.mbg.model.SmsHomeBrand;
import cn.zcscloud.mall.service.SmsHomeBrandService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SmsHomeBrandServiceImpl extends ServiceImpl<SmsHomeBrandMapper, SmsHomeBrand> implements SmsHomeBrandService {
    @Override
    public int updateList(List<SmsHomeBrand> homeBrandList) {
        int count = 0;
        for (SmsHomeBrand smsHomeBrand : homeBrandList) {
            LambdaQueryWrapper<SmsHomeBrand> wrapper = new LambdaQueryWrapper<>();
            wrapper.eq(SmsHomeBrand::getBrandName,smsHomeBrand.getBrandName());
            List<SmsHomeBrand> list = this.list(wrapper);
            if(!list.isEmpty()) continue;
            this.save(smsHomeBrand);
            count++;
        }
        return count;
    }
}
